import { IPSSysEAIDataType } from './ipssys-eaidata-type';
import { IPSSysEAIElement } from './ipssys-eaielement';
import { IPSSysEAIElementAttr } from './ipssys-eaielement-attr';
import { IPSSysEAIScheme } from './ipssys-eaischeme';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysEAIElementAttrImpl extends PSModelObjectImpl implements IPSSysEAIElementAttr {
  get attrTag(): string {
    return this.M.attrTag;
  }

  get attrTag2(): string {
    return this.M.attrTag2;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get defaultValue(): string {
    return this.M.defaultValue;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get elementAttrType(): 'SIMPLE' | 'GROUP' {
    return this.M.elementAttrType;
  }

  get fixedValue(): string {
    return this.M.fixedValue;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected pssyseaidatatype: IPSSysEAIDataType | null = null;

  getPSSysEAIDataType(): IPSSysEAIDataType | null {
    if (this.pssyseaidatatype != null) return this.pssyseaidatatype;
    const value = this.M.getPSSysEAIDataType;
    if (value == null) {
      return null;
    }
    const ipssyseaischeme = this.getParentPSModelObject('eai.IPSSysEAIScheme') as IPSSysEAIScheme;
    if (ipssyseaischeme != null) {
      this.pssyseaidatatype = ipssyseaischeme.findPSSysEAIDataType(value);
    }
    return this.pssyseaidatatype;
  }

  get psSysEAIDataType(): IPSSysEAIDataType | null {
    return this.getPSSysEAIDataType();
  }

  getPSSysEAIDataTypeMust(): IPSSysEAIDataType {
    const value = this.getPSSysEAIDataType();
    if (value == null) {
      throw new Error('未指定集成数据类型');
    }
    return value;
  }

  protected refpssyseaielement: IPSSysEAIElement | null = null;

  getRefPSSysEAIElement(): IPSSysEAIElement | null {
    if (this.refpssyseaielement != null) return this.refpssyseaielement;
    const value = this.M.getRefPSSysEAIElement;
    if (value == null) {
      return null;
    }
    const ipssyseaischeme = this.getParentPSModelObject('eai.IPSSysEAIScheme') as IPSSysEAIScheme;
    if (ipssyseaischeme != null) {
      this.refpssyseaielement = ipssyseaischeme.findPSSysEAIElement(value);
    }
    return this.refpssyseaielement;
  }

  get refPSSysEAIElement(): IPSSysEAIElement | null {
    return this.getRefPSSysEAIElement();
  }

  getRefPSSysEAIElementMust(): IPSSysEAIElement {
    const value = this.getRefPSSysEAIElement();
    if (value == null) {
      throw new Error('未指定引用属性组');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get allowEmpty(): boolean {
    return this.M.allowEmpty;
  }

  get cls(): string {
    return 'PSSysEAIElementAttrImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'eai.IPSEAIElementAttr' || cls == 'eai.IPSSysEAIElementAttr') return true;
    return super.instanceof(cls);
  }
}
